package com.wenli.lt.service.impl;

import com.wenli.lt.entity.Img;
import com.wenli.lt.mapper.ImgMapper;
import com.wenli.lt.service.IImgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lt
 * @since 2021-03-23
 */
@Service
public class ImgServiceImpl extends ServiceImpl<ImgMapper, Img> implements IImgService {

    @Autowired
    ImgMapper imgMapper;
    @Override
    public Boolean saveGoodsImg(String goodId, List<String> imgs) {
        List<Img> list = new ArrayList();
        for (int i = 0; i < imgs.size(); i++) {
            Img img = new Img();
            img.setImageId(UUID.randomUUID().toString().replace("-",""));
            img.setGoodsId(goodId);
            img.setImageUrl(imgs.get(i));
            list.add(img);
        }
        imgMapper.insertList(list);
        return true;
    }
}
